function radixSort(arr){
	const maxDigit = getMaxDigit(arr)
	for(let i =0; i< maxDigit; i++){
		const buckets = Array.from({length:10},()=>[])
		for(let j = 0; j<arr.length;j++){
			const bucketIndex = getDigitValue(arr[j], i)
			buckets[bucketIndex].push(arr[j])
		}
		arr = [...buckets.flat()]
	}
	return arr
}

function getMaxDigit(arr){
	let max = 0
	for(let i=0;i<arr.length;i++){
		max = Math.max(max, arr[i].toString().length)
	}
	return max
}

function getDigitValue(num, digit){
	return Math.floor(num/ Math.pow(10, digit))%10
}

const arr = [111,222,999,333,888,110,102]
const res= radixSort(arr)
console.log(res,'🍉')